import 'package:flutter/material.dart';
import 'package:flutter_learn_demo/main_screen_page.dart';
import 'package:flutter_learn_demo/scroll_controller_test.dart';
import 'package:flutter_learn_demo/scroll_notification_test.dart';
import 'package:flutter_learn_demo/turnbox.dart';
import 'buttons.dart';
import 'notifier/change_notifier_test.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',

      theme: ThemeData(
        primarySwatch: Colors.blue,
        primaryColor: Colors.blue
      ),

      //路由表注册
      routes: {
        "toMainScreen":(context) => const MainScreenPage(title: "Flutter Demo"),
        "buttons":(context) => const ButtonsCase(),
        "turnbox":(context) => const TurnBoxRoute(),
        "scrollcontrollertest":(context) => const ScrollControllerDemo(),
        "scrollnotificationtest":(context) => const ScrollNotificationDemo(),
      },

      home: const LoadingPage(title: 'Flutter Demo Home Page'),
    );
  }
}

class LoadingPage extends StatefulWidget {
  const LoadingPage({super.key, required this.title});
  final String title;
  @override
  State<LoadingPage> createState() => _LoadingPageState();
}

class _LoadingPageState extends State<LoadingPage> {
  @override
  void initState() {
    super.initState();

    //延时跳转到下一页面
    Future.delayed(const Duration(seconds: 3), () {
      Navigator.of(context).pushReplacementNamed("toMainScreen",arguments: "1234");
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      // appBar: AppBar(
      //   title: Text(widget.title),
      // ),
      // body: Center(
      //   child: Column(
      //     mainAxisAlignment: MainAxisAlignment.center,
      //     children: <Widget>[
      //       const Text(
      //         'You have pushed the button this many times:',
      //       ),
      //       Text(
      //         '$_counter',
      //         style: Theme.of(context).textTheme.headlineMedium,
      //       ),
      //     ],
      //   ),
      // ),
      // floatingActionButton: FloatingActionButton(
      //   onPressed: _incrementCounter,
      //   tooltip: 'Increment',
      //   child: const Icon(Icons.add),
      // ),

      //设置背景颜色
      body: Container(
           color: Colors.blue,
      ),

      //加载图片
      // body:  new Container(
      //   child:new  Image.asset("images/loading.png"),
      // )

    );
  }
}
